home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / GRAPHICS / IMGLIB95 / UIMAGE.PA_ / UIMAGE.PA
Text File  |  1996-03-31  |  34KB  |  1,016 lines

  1. {
  2. Written by Jan Dekkers and Kevin Adams (c) 1995, 1996. If you are a non
  3. registered client, you may use or alter this demo only for evaluation
  4. purposes.
  5.  
  6. Copyright by SkyLine Tools. All rights reserved.
  7.  
  8. Part of Imagelib VCL/DLL Library.
  9. }
  10.  
  11. unit Uimage;
  12.  
  13. {Includes settings to compile in either 16 or 32 bit}
  14. {$I DEFILIB.INC}
  15.  
  16. interface
  17.  
  18. uses
  19. {$IFDEF DEL32}
  20.   Windows,
  21. {$ELSE}
  22.   WinTypes,
  23.   WinProcs,
  24. {$ENDIF}
  25.   DLL95V1,    {ImageLib Dll interface and misc. functions}
  26.   SysUtils,
  27.   Messages,
  28.   Classes,
  29.   Graphics,
  30.   Controls,
  31.   Forms,
  32.   Dialogs,
  33.   StdCtrls,
  34.   FileCtrl,
  35.   Spin,
  36.   Buttons,
  37.   ExtCtrls,
  38.   Gauges,
  39.   printers,
  40.   Menus,
  41.   Uabout,
  42.   UFullscr,   {Full screen display unit}
  43.   U_p_size,   {Printer size unit}
  44.   TMultiP, Preview;    {PMultiImage VCL component}
  45.  
  46.  
  47.  
  48. type
  49.   TViewImageForm = class(TForm)
  50.     DriveComboBox1     : TDriveComboBox;
  51.     DirectoryListBox1  : TDirectoryListBox;
  52.     FileListBox1       : TFileListBox;
  53.     SaveDialog1        : TSaveDialog;
  54.     SaveButton         : TBitBtn;
  55.     QualitySpin        : TSpinEdit;
  56.     Smoothspin         : TSpinEdit;
  57.     QualityLabel       : TLabel;
  58.     SmoothLabel        : TLabel;
  59.     GroupBox1          : TGroupBox;
  60.     res4               : TRadioButton;
  61.     res24              : TRadioButton;
  62.     res8               : TRadioButton;
  63.     MainMenu1          : TMainMenu;
  64.     N1                 : TMenuItem;
  65.     O1                 : TMenuItem;
  66.     N2                 : TMenuItem;
  67.     E1                 : TMenuItem;
  68.     A1                 : TMenuItem;
  69.     OpenDialog1        : TOpenDialog;
  70.     N4                 : TMenuItem;
  71.     Print1             : TMenuItem;
  72.     PrintSetup1        : TMenuItem;
  73.     PrinterSetupDialog1: TPrinterSetupDialog;
  74.     PrintDialog1       : TPrintDialog;
  75.     Label9             : TLabel;
  76.     Label10            : TLabel;
  77.     Label11            : TLabel;
  78.     Label12            : TLabel;
  79.     Label13            : TLabel;
  80.     Label14            : TLabel;
  81.     Label15            : TLabel;
  82.     Edit1              : TEdit;
  83.     Edit2              : TEdit;
  84.     Edit3              : TEdit;
  85.     Edit4              : TEdit;
  86.     Edit5              : TEdit;
  87.     Edit6              : TEdit;
  88.     Edit7              : TEdit;
  89.     GetInfoChecked     : TCheckBox;
  90.     Label8             : TLabel;
  91.     Edit8              : TEdit;
  92.     BitBtn1            : TBitBtn;
  93.     Edit9              : TMenuItem;
  94.     Cut1               : TMenuItem;
  95.     Copy1              : TMenuItem;
  96.     Paste1             : TMenuItem;
  97.     ScrollBar1         : TScrollBar;
  98.     N5                 : TMenuItem;
  99.     CreateMessage1     : TMenuItem;
  100.     CheckBox2          : TCheckBox;
  101.     BitBtn2            : TBitBtn;
  102.     BitBtn3            : TBitBtn;
  103.     BitBtn4            : TBitBtn;
  104.     CreateCreditMessage1: TMenuItem;
  105.     BitBtn5            : TBitBtn;
  106.     Scanning: TBitBtn;
  107.     GroupBox2          : TGroupBox;
  108.     SaveRes4           : TRadioButton;
  109.     SaveRes24          : TRadioButton;
  110.     SaveRes8           : TRadioButton;
  111.     CheckBox3          : TCheckBox;
  112.     SaveResJpegGray    : TRadioButton;
  113.     SaveRes4System     : TRadioButton;
  114.     res4System         : TRadioButton;
  115.     CheckBox4          : TCheckBox;
  116.     resAuto            : TRadioButton;
  117.     SaveResAuto        : TRadioButton;
  118.     ScrollBox1         : TScrollBox;
  119.     MultiImage1        : TPMultiImage;
  120.     Edit10             : TEdit;
  121.     Label1             : TLabel;
  122.     BitBtn7            : TBitBtn;
  123.     Button3: TButton;
  124.     Button2: TButton;
  125.     Button4: TButton;
  126.     Label2: TLabel;
  127.     CheckBox1: TCheckBox;
  128.     N6: TMenuItem;
  129.     Gauge1: TGauge;
  130.     TiffCombo: TComboBox;
  131.     Label3: TLabel;
  132.     N3: TMenuItem;
  133.     Scan1: TMenuItem;
  134.     SelectScanner1: TMenuItem;
  135.     N7: TMenuItem;
  136.     LoadresourcefromDelphiExe1: TMenuItem;
  137.     res1: TRadioButton;
  138.     ThumbPreview1: TThumbPreview;
  139.     OpenUsingThumbnails1: TMenuItem;
  140.     procedure DriveComboBox1Change(Sender: TObject);
  141.     procedure DirectoryListBox1Change(Sender: TObject);
  142.     procedure FileListBox1Change(Sender: TObject);
  143.     procedure SstretchOnOff(Sender: TObject);
  144.     procedure FormCreate(Sender: TObject);
  145.     procedure resClick(Sender: TObject);
  146.     procedure SaveButtonClick(Sender: TObject);
  147.     procedure MultiImage1Click(Sender: TObject);
  148.     procedure E1Click(Sender: TObject);
  149.     procedure O1Click(Sender: TObject);
  150.     procedure A1Click(Sender: TObject);
  151.     procedure Print1Click(Sender: TObject);
  152.     procedure PrintSetup1Click(Sender: TObject);
  153.     procedure GetInfoCheckedClick(Sender: TObject);
  154.     procedure BitBtn1Click(Sender: TObject);
  155.     procedure Cut1Click(Sender: TObject);
  156.     procedure Copy1Click(Sender: TObject);
  157.     procedure Paste1Click(Sender: TObject);
  158.     procedure ScrollBar1Change(Sender: TObject);
  159.     procedure SmoothspinChange(Sender: TObject);
  160.     procedure QualitySpinChange(Sender: TObject);
  161.     procedure CheckBox2Click(Sender: TObject);
  162.     procedure BitBtn2Click(Sender: TObject);
  163.     procedure BitBtn3Click(Sender: TObject);
  164.     procedure BitBtn4Click(Sender: TObject);
  165.     procedure BitBtn5Click(Sender: TObject);
  166.     procedure BitBtn6Click(Sender: TObject);
  167.     procedure SaveResClick(Sender: TObject);
  168.     procedure CheckBox4Click(Sender: TObject);
  169.     procedure BitBtn7Click(Sender: TObject);
  170.     procedure MultiImage1MouseDown(Sender: TObject; Button: TMouseButton;
  171.       Shift: TShiftState; X, Y: Integer);
  172.     procedure MultiImage1MouseUp(Sender: TObject; Button: TMouseButton;
  173.       Shift: TShiftState; X, Y: Integer);
  174.     procedure Button3Click(Sender: TObject);
  175.     procedure Button2Click(Sender: TObject);
  176.     procedure Button4Click(Sender: TObject);
  177.     procedure MultiImage1MouseMove(Sender: TObject; Shift: TShiftState; X,
  178.       Y: Integer);
  179.     procedure SstretchRatioOnOff(Sender: TObject);
  180.     procedure TiffComboChange(Sender: TObject);
  181.     procedure Scan1Click(Sender: TObject);
  182.     procedure SelectScanner1Click(Sender: TObject);
  183.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  184.     procedure OpenUsingThumbnails1Click(Sender: TObject);
  185.   private
  186.     { Private declarations }
  187.    oldsavefiles   : TstringList;
  188.    oldreadfiles   : TstringList;
  189.    pointStart     : TPoint;
  190.    pointEnd       : TPoint;
  191.    bRightDown     : Boolean;
  192.    procedure DrawRubberband;
  193.    procedure DisPlayInfo(dis : boolean);
  194.    Procedure Trigger(Sender : TObject; Var Done : Boolean);
  195.   public
  196.     { Public declarations }
  197.   end;
  198.  
  199. var
  200.   ViewImageForm: TViewImageForm;
  201.  
  202. implementation
  203.  
  204. {$R *.DFM}
  205. {$IFDEF DEL32}
  206.   {$R BLIT32.RES}  {This contains a 256 color bitmap}
  207. {$ELSE}
  208.   {$R BLIT16.RES}  {This contains a 256 color bitmap}
  209. {$ENDIF}
  210.  
  211.  
  212.  
  213. {---------------------------------------------------------------------}
  214.  
  215. {Changed in version 2.21 from a procedure to a function with cdecl.
  216.  To cancel return a 0 else return a 1}
  217.  
  218.  Function ImageLibCallBack(i : integer) : integer; cdecl; export;
  219. {Callback function from the dll, CDECL and EXPORT ARE REQUIRED}
  220. begin
  221.  if Application.Terminated then begin
  222.    {User wants to terminate the program. Pass a 0 to the dll}
  223.    Result:=0;
  224.   end else begin
  225.   {Be nice to others <g>}
  226.    Application.ProcessMessages;
  227.    {process a Gauge}
  228.    if ViewImageForm <> Nil then
  229.     ViewImageForm.Gauge1.Progress:=i;
  230.    {tell the dll that everything is OK}
  231.    Result:=1;
  232.    end;
  233. end;
  234. {---------------------------------------------------------------------}
  235.  
  236. procedure TViewImageForm.DriveComboBox1Change(Sender: TObject);
  237. {update the drive of DirectoryListBox1 with the drive of DriveComboBox1}
  238. begin
  239.   DirectoryListBox1.Drive := DriveComboBox1.Drive;
  240. end;
  241. {---------------------------------------------------------------------}
  242.  
  243. procedure TViewImageForm.DisPlayInfo(dis : boolean);
  244. begin
  245.     {If scrolling message then show the speed scroll bar}
  246.     if (MultiImage1.BFileType = 'SCM') or (MultiImage1.BFileType = 'CMS') then begin
  247.     {Show it}
  248.      ScrollBar1.Visible:=true;
  249.      {set the speed/position}
  250.      ScrollBar1.Position:=MultiImage1.MsgSpeed;
  251.     end else
  252.      ScrollBar1.Visible:=False;
  253.  
  254.     if dis then begin
  255.        {display the image info}
  256.        Edit1.Text:=IntToStr(MultiImage1.Bwidth);
  257.        Edit2.Text:=IntToStr(MultiImage1.BHeight);
  258.        Edit3.Text:=IntToStr(MultiImage1.Bbitspixel);
  259.        Edit4.Text:=IntToStr(MultiImage1.Bplanes);
  260.        Edit5.Text:=IntToStr(MultiImage1.Bnumcolors);
  261.        Edit6.Text:=MultiImage1.BFileType;
  262.        Edit7.Text:=MultiImage1.Bcompression;
  263.        Edit8.Text:=IntToStr(MultiImage1.BSize);
  264.      end else begin
  265.       {set the image info to ''}
  266.        Edit1.Text:='';
  267.        Edit2.Text:='';
  268.        Edit3.Text:='';
  269.        Edit4.Text:='';
  270.        Edit5.Text:='';
  271.        Edit6.Text:='';
  272.        Edit7.Text:='';
  273.        Edit8.Text:='';
  274.      end;
  275. end;
  276. {---------------------------------------------------------------------}
  277.  
  278. procedure TViewImageForm.DirectoryListBox1Change(Sender: TObject);
  279. {update the directory of FileListBox1 with the directory of FileListBox1}
  280. begin
  281.   FileListBox1.Directory := DirectoryListBox1.Directory;
  282. end;
  283. {---------------------------------------------------------------------}
  284.  
  285. procedure TViewImageForm.FileListBox1Change(Sender: TObject);
  286. {Display the image of the FileListBox1.filename}
  287. begin
  288.   {Reset image sizes}
  289.   MultiImage1.Height:=239;
  290.   MultiImage1.Width:=334;
  291.  
  292.  {set hourglass cursor}
  293.   screen.cursor:=crHourGlass;
  294.  
  295.  {delete the old image}
  296.   MultiImage1.imagename:='';
  297.  
  298.  {display an image using the vcl}
  299.   MultiImage1.imagename:=FileListBox1.filename;
  300.  
  301.   {Request fileinfo from the DLL}
  302.   if GetInfoChecked.Checked then
  303.    DisplayInfo(true) else DisplayInfo(false);
  304.  
  305.   {Reset the gauge}
  306.   Gauge1.Progress:=0;
  307.  
  308.  {add filename to the history list of the open dialog}
  309.   oldreadfiles.add(FileListBox1.filename);
  310.  
  311.  {copy the stringlist to the historylist}
  312.   OpenDialog1.historylist:=oldreadfiles;
  313.  
  314.   {set default cursor}
  315.   screen.cursor:=crDefault;
  316. end;
  317. {---------------------------------------------------------------------}
  318.  
  319. procedure TViewImageForm.SstretchOnOff(Sender: TObject);
  320. {set stretch mode}
  321. begin
  322.   MultiImage1.Stretch:=CheckBox3.Checked;
  323.   CheckBox1.Checked:=False;
  324.   if (MultiImage1.Stretch) or (MultiImage1.StretchRatio) then begin
  325.     {Reset image sizes}
  326.     MultiImage1.AutoSize:=False;
  327.     MultiImage1.Height:=239;
  328.     MultiImage1.Width:=334;
  329.     ScrollBox1.ScrollInView(MultiImage1);
  330.     Button2.Enabled:=True;
  331.     Button3.Enabled:=True;
  332.     Button4.Enabled:=True;
  333.   end else begin
  334.     MultiImage1.AutoSize:=True;
  335.     Button2.Enabled:=False;
  336.     Button3.Enabled:=False;
  337.     Button4.Enabled:=False;
  338.   end;
  339. end;
  340. {---------------------------------------------------------------------}
  341.  
  342. procedure TViewImageForm.SstretchRatioOnOff(Sender: TObject);
  343. {set stretch Ratio mode}
  344. begin
  345.   MultiImage1.Stretchratio:=CheckBox1.Checked;
  346.   CheckBox3.Checked:=False;  
  347.   if (MultiImage1.Stretch) or (MultiImage1.StretchRatio) then begin
  348.     {Reset image sizes}
  349.     MultiImage1.AutoSize:=False;
  350.     MultiImage1.Height:=239;
  351.     MultiImage1.Width:=334;
  352.     ScrollBox1.ScrollInView(MultiImage1);
  353.     Button2.Enabled:=True;
  354.     Button3.Enabled:=True;
  355.     Button4.Enabled:=True;
  356.   end else begin
  357.     MultiImage1.AutoSize:=True;
  358.     Button2.Enabled:=False;
  359.     Button3.Enabled:=False;
  360.     Button4.Enabled:=False;
  361.   end;
  362. end;
  363. {---------------------------------------------------------------------}
  364.  
  365. procedure TViewImageForm.FormCreate(Sender: TObject);
  366. {what we do on create}
  367. begin
  368.     Printersize:=TPrintersize.Create(Application);
  369.     {Define the callback procedure}
  370.     TPMultiImageCallBack:=ImageLibCallBack;
  371.  
  372.     {set the value of the QualitySpin to the value of JPegSaveQuality}
  373.     QualitySpin.value:=MultiImage1.JPegSaveQuality;
  374.  
  375.     {set the value of the Smoothspin to the value of JPegSaveSmooth}
  376.     Smoothspin.value:=MultiImage1.JPegSaveSmooth;
  377.  
  378.     {create temporary history stringlists}
  379.     oldsavefiles := TstringList.create;
  380.     oldreadfiles := TstringList.create;
  381.  
  382.     {IMPORTANT}
  383.     {This is the moving engine for all the messages. Since an application
  384.     can have only one OnIdle Trigger, this trigger needs to be subdivided
  385.     by all your moving and animated objects. In this particular case the
  386.     function is called TRIGGER but you can name it as you want as long
  387.     you have a procedure named the same.}
  388.     Application.OnIdle:=Trigger;
  389.  
  390.     {Only enable this if delphi is active}
  391. {$IFDEF DEL32}
  392.     LoadresourcefromDelphiExe1.Enabled:=(GetModuleHandle('DELPHI32.EXE') <> 0);
  393. {$ELSE}
  394.     LoadresourcefromDelphiExe1.Enabled:=(GetModuleHandle('DELPHI.EXE') <> 0);
  395. {$ENDIF}
  396.  
  397.     SstretchOnOff(Sender);
  398. end;
  399. {---------------------------------------------------------------------}
  400.  
  401. Procedure TViewImageForm.Trigger(Sender : TObject; Var Done : Boolean);
  402. begin
  403.    {This function is called when your app is idle. Subdivide the
  404.     trigger event to your TMultiImage objects who may need one.
  405.     If no Message is active it will not take up significant time}
  406.     MultiImage1.Trigger;
  407. end;
  408. {---------------------------------------------------------------------}
  409.  
  410. procedure TViewImageForm.resClick(Sender: TObject);
  411. {Set the read resolution to either 16, 256 or true color in the vcl}
  412. begin
  413.  {set show resolution to 1 bit monochrome black and white}
  414.  if Res1.checked  then MultiImage1.ImageReadRes:=lMonoChrome;
  415.  
  416.  {set show resolution to 4 bit 16 color using the system's colors}
  417.  if Res4System.checked  then MultiImage1.ImageReadRes:=lColorVGA;
  418.  
  419.  {set show resolution to 4 bit 16 color}
  420.  if res4.checked  then MultiImage1.ImageReadRes:=lColor16;
  421.  
  422.  {set show resolution to 8 bit 256 color}
  423.  if res8.checked  then MultiImage1.ImageReadRes:=lColor256;
  424.  
  425.  {set show resolution to 24 bit true color}
  426.  if res24.checked then MultiImage1.ImageReadRes:=lColorTrue;
  427.  
  428.  {Let ImageLib determine the best resolution}
  429.  if resAuto.checked then MultiImage1.ImageReadRes:=lAutoMatic;
  430. end;
  431. {---------------------------------------------------------------------}
  432.  
  433. procedure TViewImageForm.SaveResClick(Sender: TObject);
  434. {Set the save  resolution to either 16, 256 or true color in the vcl}
  435. begin
  436.  {set Jpeg save resolution to GrayScale (Other formats will neglect
  437.  this parameter and set it to 8 bit}
  438.  if SaveResJpegGray.checked  then MultiImage1.ImageWriteRes:=sJpegGray;
  439.  
  440.  {set save resolution to 4 bit 16 color using the system's colors}
  441.  if SaveRes4System.checked  then MultiImage1.ImageWriteRes:=sColorVGA;
  442.  
  443.  {set save resolution to 4 bit 16 color}
  444.  if Saveres4.checked  then MultiImage1.ImageWriteRes:=sColor16;
  445.  
  446.  {set save resolution to 8 bit 256 color}
  447.  if Saveres8.checked  then MultiImage1.ImageWriteRes:=sColor256;
  448.  
  449.  {set save resolution to 24 bit true color}
  450.  if Saveres24.checked then MultiImage1.ImageWriteRes:=sColorTrue;
  451.  
  452.  {Let ImageLib determine the best resolution}
  453.  if SaveResAuto.checked then MultiImage1.ImageWriteRes:=sAutoMatic;
  454. end;
  455.  
  456. {---------------------------------------------------------------------}
  457.  
  458. procedure TViewImageForm.SaveButtonClick(Sender: TObject);
  459. {save a jpeg or bmp}
  460. begin
  461.  {Set various filters}
  462.  if MultiImage1.BFileType = 'SCM' then begin
  463.   SaveDialog1.Filename:='*.SCM';
  464.   SaveDialog1.Filter:='Scroll message|*.scm';
  465.  end else
  466.  if MultiImage1.BFileType = 'CMS' then begin
  467.   SaveDialog1.Filename:='*.CMS';
  468.   SaveDialog1.Filter:='Credit message|*.cms';
  469.  end else begin
  470.   SaveDialog1.Filename:='*.jpg';
  471.   SaveDialog1.Filter:='jpeg|*.jpg|bmp|*.bmp|gif|*.gif|pcx|*.pcx|png|*.png|tif|*.tif';
  472.  end;
  473.  
  474.  {open save dialog}
  475.  if SaveDialog1.execute then begin
  476.  
  477.  {set hourglass cursor}
  478.   screen.cursor:=crHourGlass;
  479.  
  480.   {save it if the extension is png}
  481.   if UpperCase(ExtractFileExt(SaveDialog1.Filename)) =  '.PNG' then
  482.     MultiImage1.SaveAsPNG(SaveDialog1.FileName);
  483.  
  484.   {save it if the extension is pcx}
  485.   if UpperCase(ExtractFileExt(SaveDialog1.Filename)) =  '.PCX' then
  486.     MultiImage1.SaveAsPCX(SaveDialog1.FileName);
  487.  
  488.   {save it if the extension is pcx}
  489.   if UpperCase(ExtractFileExt(SaveDialog1.Filename)) =  '.GIF' then
  490.     MultiImage1.SaveAsGIF(SaveDialog1.FileName);
  491.  
  492.   {save it if the extension is jpg}
  493.   if UpperCase(ExtractFileExt(SaveDialog1.Filename)) =  '.JPG' then
  494.     MultiImage1.SaveAsJpg(SaveDialog1.FileName);
  495.  
  496.   {save it if the extension is bmp}
  497.   if UpperCase(ExtractFileExt(SaveDialog1.Filename)) =  '.BMP' then
  498.     MultiImage1.SaveAsBMP(SaveDialog1.FileName);
  499.  
  500.  {save it if the extension is SCM}
  501.   if UpperCase(ExtractFileExt(SaveDialog1.Filename)) =  '.SCM' then
  502.     MultiImage1.SaveCurrentMessage(SaveDialog1.FileName);
  503.  
  504.  {save it if the extension is CMS}
  505.   if UpperCase(ExtractFileExt(SaveDialog1.Filename)) =  '.CMS' then
  506.     MultiImage1.SaveCurrentCreditMessage(SaveDialog1.FileName);
  507.  
  508.  {save it if the extension is TIF}
  509.   if UpperCase(ExtractFileExt(SaveDialog1.Filename)) =  '.TIF' then
  510.     MultiImage1.SaveAsTIF(SaveDialog1.FileName);
  511.  
  512.  {add filename to the history list of the save dialog}
  513.   oldSavefiles.add(SaveDialog1.filename);
  514.  
  515.  {copy the stringlist to the historylist}
  516.   SaveDialog1.historylist:=oldSavefiles;
  517.  
  518.  {set default cursor}
  519.   screen.cursor:=crDefault;
  520.  
  521.   {update the filelist box sothat the file saved shows up}
  522.   FileListBox1.Update;
  523.  end;
  524. end;
  525. {---------------------------------------------------------------------}
  526.  
  527. procedure TViewImageForm.MultiImage1Click(Sender: TObject);
  528. {show fullscreen}
  529. begin
  530.   {copy image to fullscreen image}
  531.   FullSlide.MultiImage1.Picture.Graphic:=MultiImage1.Picture.Graphic;
  532.   {show the image fulscreen}
  533.   FullSlide.showmodal;
  534. end;
  535. {---------------------------------------------------------------------}
  536.  
  537. procedure TViewImageForm.E1Click(Sender: TObject);
  538. {exit the program}
  539. begin
  540.  close;
  541. end;
  542. {---------------------------------------------------------------------}
  543.  
  544. procedure TViewImageForm.O1Click(Sender: TObject);
  545. {open a image using the open dialog}
  546. begin
  547.   if OpenDialog1.execute then begin
  548.  
  549.     SstretchOnOff(Sender);
  550.     {Reset image sizes}
  551.     MultiImage1.Height:=239;
  552.     MultiImage1.Width:=334;
  553.  
  554.    {set hourglass cursor}
  555.     screen.cursor:=crHourGlass;
  556.  
  557.    {delete the old image}
  558.     MultiImage1.imagename:='';
  559.  
  560.     {display an image using the vcl}
  561.     MultiImage1.imagename:=OpenDialog1.filename;
  562.  
  563.    {Request fileinfo from the DLL}
  564.    {Note, fileinfo will not work on WMF and ICO}
  565.     if GetInfoChecked.Checked then
  566.       DisplayInfo(true) else DisplayInfo(false);
  567.  
  568.     {reset the gauge}
  569.     Gauge1.Progress:=0;
  570.  
  571.    {add filename to the history list of the open dialog}
  572.     oldreadfiles.add(OpenDialog1.filename);
  573.  
  574.    {copy the stringlist to the historylist}
  575.     OpenDialog1.historylist:=oldreadfiles;
  576.  
  577.    {set default cursor}
  578.     screen.cursor:=crDefault;
  579.   end;
  580. end;
  581. {---------------------------------------------------------------------}
  582.  
  583. procedure TViewImageForm.A1Click(Sender: TObject);
  584. {about box}
  585. begin
  586. {Copy the image to the image of he about box}
  587.  AboutBox.Image1.Picture.Graphic:=MultiImage1.Picture.Graphic;
  588. {show the about box}
  589.  AboutBox.showmodal;
  590. end;
  591. {---------------------------------------------------------------------}
  592.  
  593. procedure TViewImageForm.Print1Click(Sender: TObject);
  594. {Print image}
  595. begin
  596.   if PrintDialog1.execute then begin
  597.   {Initialize the height spinedit of the printsize dialog box}
  598.    Printersize.HeigthSpinEdit.Value:=MultiImage1.Picture.Height;
  599.    {Initialize the width spinedit of the printsize dialog box}
  600.    Printersize.WidthSpinEdit.Value:=MultiImage1.Picture.Width;
  601.    {Show it}
  602.    Printersize.ShowModal;
  603.    if Printersize.Modalresult = mrok then
  604.     {print TMultiImage}
  605.      MultiImage1.PrintMultiImage(0,0,Printersize.WidthSpinEdit.Value,Printersize.HeigthSpinEdit.Value);
  606.    {Hide it if done}
  607.    Printersize.hide;
  608.   end;
  609. end;
  610. {---------------------------------------------------------------------}
  611.  
  612. procedure TViewImageForm.PrintSetup1Click(Sender: TObject);
  613. {Set up printer}
  614. begin
  615.   PrinterSetupDialog1.Execute;
  616. end;
  617. {---------------------------------------------------------------------}
  618.  
  619. procedure TViewImageForm.GetInfoCheckedClick(Sender: TObject);
  620. {depending on the state of the checkbox,  display or not display info}
  621. begin
  622.  DisPlayInfo(GetInfoChecked.Checked);
  623. end;
  624. {---------------------------------------------------------------------}
  625. {---------------------------------------------------------------------}
  626.  
  627. procedure TViewImageForm.BitBtn1Click(Sender: TObject);
  628. var
  629.   RunAfterCreate : Boolean;
  630. begin
  631.     {Create a new message using the message editor}
  632.     {boolean indicating to run the message after creation}
  633.     RunAfterCreate:=True;
  634.  
  635.     {CreateMessage takes a pathname as the initial path to save the
  636.      message and a boolean to run it. For Instance:
  637.     {MultiImage1.CreateMessage('c:\',true);}
  638.     MultiImage1.CreateMessage(ExtractFilePath(Application.Exename),RunAfterCreate);
  639.  
  640.     {Show new message in listbox}
  641.     FileListBox1.Update;
  642. end;
  643. {---------------------------------------------------------------------}
  644.  
  645. {---------------------------------------------------------------------}
  646.  
  647. procedure TViewImageForm.Cut1Click(Sender: TObject);
  648. begin
  649. {Cut Image and Copy it to the clipboard}
  650.   MultiImage1.CutToClipboard
  651. end;
  652. {---------------------------------------------------------------------}
  653.  
  654. procedure TViewImageForm.Copy1Click(Sender: TObject);
  655. begin
  656. {Copy Image to the clipboard}
  657.   MultiImage1.CopyToClipboard;
  658. end;
  659. {---------------------------------------------------------------------}
  660.  
  661. procedure TViewImageForm.Paste1Click(Sender: TObject);
  662. begin
  663. {Paste Image from the clipboard}
  664.   MultiImage1.PasteFromClipboard;
  665. end;
  666. {---------------------------------------------------------------------}
  667.  
  668. procedure TViewImageForm.ScrollBar1Change(Sender: TObject);
  669. begin
  670.  {Change the speed of a srolling message}
  671.   MultiImage1.MsgSpeed:=ScrollBar1.Position;
  672. end;
  673. {---------------------------------------------------------------------}
  674.  
  675.  
  676. procedure TViewImageForm.SmoothspinChange(Sender: TObject);
  677. begin
  678.     {set the value of the JPegSaveSmooth}
  679.     MultiImage1.JPegSaveSmooth:=Smoothspin.value;
  680. end;
  681. {---------------------------------------------------------------------}
  682.  
  683. procedure TViewImageForm.QualitySpinChange(Sender: TObject);
  684. begin
  685.     {set the value of the JPegSaveQuality}
  686.     MultiImage1.JPegSaveQuality:=QualitySpin.value;
  687. end;
  688. {---------------------------------------------------------------------}
  689.  
  690. procedure TViewImageForm.CheckBox2Click(Sender: TObject);
  691. begin
  692. {Set read image dither }
  693.     MultiImage1.ImageDither:=CheckBox2.Checked;
  694. end;
  695. {---------------------------------------------------------------------}
  696.  
  697. procedure TViewImageForm.BitBtn2Click(Sender: TObject);
  698. var
  699.   RunAfterCreate : Boolean;
  700. begin
  701.     {Create a new message using the message editor}
  702.     {boolean indicating to run the message after creation}
  703.     RunAfterCreate:=True;
  704.  
  705.     {CreateCreditMessage takes a pathname as the initial path to save the
  706.      message and a boolean to run it. For Instance:
  707.     {MultiImage1.CreateCreditMessage('c:\',true);}
  708.     MultiImage1.CreateCreditMessage(ExtractFilePath(Application.Exename),RunAfterCreate);
  709.  
  710.     {Show new message in listbox}
  711.     FileListBox1.Update;
  712. end;
  713. {---------------------------------------------------------------------}
  714.  
  715. procedure TViewImageForm.BitBtn5Click(Sender: TObject);
  716.  {Load a BMP image from any executable or dll.
  717.   Note that the dll or exe needs to be loaded in order
  718.   to find its module handle}
  719. begin
  720.   {Indicate in which program the BMP Lives. For instance:
  721.   MultiImage1.ResProgName:='';
  722.   means in this executable (RES (Resource file))}
  723.   {Dont enter a path name};
  724.   MultiImage1.ResProgName:=''; {this executable linked in BLIT8.RES}
  725.  
  726.   {Name of the resource. Note that the .res indicate to the vcl
  727.   that it is a resource BMP but your resource BMP is called FRIDGE.
  728.   Incase the resource is a number put e.g: MultiImage1.ImageName:='98255.RES';}
  729.   MultiImage1.ImageName:='FRIDGE.RES';
  730.   if GetInfoChecked.Checked then
  731.    DisplayInfo(true) else DisplayInfo(false);
  732. end;
  733. {---------------------------------------------------------------------}
  734.  
  735. procedure TViewImageForm.BitBtn6Click(Sender: TObject);
  736. begin
  737.   {Indicate in which program the BMP Lives. For instance:
  738.   MultiImage1.ResProgName:='';
  739.   means in this executable (RES (Resource file))}
  740.   {Dont enter a path name};
  741.  
  742. {$IFDEF DEL32}
  743.   MultiImage1.ResProgName:='DELPHI32.EXE';
  744. {$ELSE}
  745.   MultiImage1.ResProgName:='DELPHI.EXE';
  746. {$ENDIF}
  747.  
  748.   {Name of the resource. Note that the .res indicate to the vcl
  749.   that it is a resource BMP but your resource BMP is called FRIDGE.
  750.   Incase the resource is a number put e.g: MultiImage1.ImageName:='98255.RES';}
  751.   MultiImage1.ImageName:='ATHENA.RES';
  752.   if GetInfoChecked.Checked then
  753.    DisplayInfo(true) else DisplayInfo(false);
  754. end;
  755. {---------------------------------------------------------------------}
  756.  
  757. procedure TViewImageForm.BitBtn3Click(Sender: TObject);
  758. begin
  759.    {Create A credit message on the fly}
  760.     MultiImage1.FreeMsg;
  761.    {Clear Message text if any}
  762.     MultiImage1.CreditBoxList.Clear;
  763.    {Define Message text}
  764.     MultiImage1.CreditBoxList.Add(' ImageLib');
  765.     MultiImage1.CreditBoxList.Add(' Another fine product of');
  766.     MultiImage1.CreditBoxList.Add(' SKYLINE TOOLS');
  767.     MultiImage1.CreditBoxList.Add(' Programming : Kevin Adams');
  768.     MultiImage1.CreditBoxList.Add(' Programming : Jan Dekkers');
  769.     MultiImage1.CreditBoxList.Add(' Artwork & PR: Jillian Pinsker');
  770.     MultiImage1.CreditBoxList.Add(' Management: Chris Giggey');
  771.  
  772.     {set Message font name;  Note you could do this also with a font dialog}
  773.     MultiImage1.MsgFont.Name:='Arial';
  774.    {set Message font size}
  775.     MultiImage1.MsgFont.Size:=-18;
  776.     {set Message font style}
  777.     MultiImage1.MsgFont.Style:=[fsitalic, fsbold];
  778.     {set Message font color}
  779.     MultiImage1.MsgFont.Color:=clWhite;
  780.     {set Message background. Note you could do this also with a color dialog}
  781.     MultiImage1.MsgBkGrnd:=clNavy;
  782.     {set Message speed from 1 is fast to 10 is slow}
  783.     MultiImage1.MsgSpeed:=5;
  784.     {Show Speed ScrollBar}
  785.     ScrollBar1.Visible:=true;
  786.     {set the speed/position}
  787.     ScrollBar1.Position:=MultiImage1.MsgSpeed;
  788.     {inititiate new message}
  789.     MultiImage1.NewCreditMessage;
  790. end;
  791. {---------------------------------------------------------------------}
  792.  
  793. procedure TViewImageForm.BitBtn4Click(Sender: TObject);
  794. begin
  795.    {create a message on the fly at MultiImage1 (Top one)}
  796.    {set Message text}
  797.     MultiImage1.MsgText:='ImageLib 3.1  A great tool to create a superb application in no time.';
  798.     {set Message font name;  Note you could do this also with a font dialog}
  799.     MultiImage1.MsgFont.Name:='Arial';
  800.    {set Message font size}
  801.     MultiImage1.MsgFont.Size:=-40;
  802.     {set Message font style}
  803.     MultiImage1.MsgFont.Style:=[fsitalic, fsbold];
  804.     {set Message font color}
  805.     MultiImage1.MsgFont.Color:=clYellow;
  806.     {set Message background. Note you could do this also with a color dialog}
  807.     MultiImage1.MsgBkGrnd:=clPurple;
  808.     {set Message speed from 1 is fast to 10 is slow}
  809.     MultiImage1.MsgSpeed:=3;
  810.     {Show Speed ScrollBar}
  811.     ScrollBar1.Visible:=true;
  812.     {set the speed/position}
  813.     ScrollBar1.Position:=MultiImage1.MsgSpeed;
  814.     {inititiate new message}
  815.     MultiImage1.NewMessage;
  816. end;
  817. {---------------------------------------------------------------------}
  818.  
  819. procedure TViewImageForm.CheckBox4Click(Sender: TObject);
  820. begin
  821.   {Use the ImageLib way of drawing. This is a 256 color problem
  822.    workaround caused by some VGA driver in delphi}
  823.   MultiImage1.ImageLibPalette:=CheckBox4.Checked;
  824.   MultiImage1.Invalidate;
  825.   {in case ImageLibPalette is not set uncheck strectch ratio}
  826.   if CheckBox1.Checked and not CheckBox4.Checked then
  827.      CheckBox1.Checked:=False;
  828. end;
  829. {---------------------------------------------------------------------}
  830.  
  831. procedure TViewImageForm.BitBtn7Click(Sender: TObject);
  832. begin
  833.   {Text on an Image}
  834.   MultiImage1.Text:=(Edit10.Text);
  835.   {Text can be shadowed}
  836.   MultiImage1.TextShadow:=True;
  837.   {Text position}
  838.   MultiImage1.TextLeft:=1;
  839.   {Text position}
  840.   MultiImage1.TextTop:=MultiImage1.ClientRect.Top;
  841.   {Text angle in degrees}
  842.   MultiImage1.TextRotate:=0;
  843.   {Text background color}
  844.   MultiImage1.TextTransParent:=True;
  845. end;
  846. {---------------------------------------------------------------------}
  847.  
  848. procedure TViewImageForm.MultiImage1MouseDown(Sender: TObject;
  849.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  850. begin
  851.    {The begin points of zooming/flipping or rotating}
  852.   bRightDown := false;
  853.   if button = mbRight then begin
  854.     MultiImage1.ResetImage;
  855.     bRightDown := true;
  856.     pointStart.X := X;
  857.     pointStart.Y := Y;
  858.     pointEnd.X := X;
  859.     pointEnd.Y := Y;
  860.   end;
  861. end;
  862. {---------------------------------------------------------------------}
  863.  
  864. procedure TViewImageForm.MultiImage1MouseUp(Sender: TObject; Button: TMouseButton;
  865.   Shift: TShiftState; X, Y: Integer);
  866. begin
  867.    if not bRightDown then exit;
  868.    if Button = mbRight then begin
  869.       DrawRubberband;
  870.       bRightDown := false;
  871.       pointEnd.X := X;
  872.       pointEnd.Y := Y;
  873.       {Zoom , flip or rotate image}
  874.       MultiImage1.TransformImage(Rect(pointStart.X, pointStart.Y, pointEnd.X, pointEnd.Y));
  875.    end;
  876. end;
  877. {---------------------------------------------------------------------}
  878.  
  879. procedure TViewImageForm.MultiImage1MouseMove(Sender: TObject;
  880.   Shift: TShiftState; X, Y: Integer);
  881. begin
  882.   if not bRightDown then exit;
  883.   DrawRubberband;
  884.   pointEnd.x := X;
  885.   pointEnd.y := Y;
  886.   DrawRubberband;
  887. end;
  888. {---------------------------------------------------------------------}
  889.  
  890. procedure TViewImageForm.DrawRubberband;
  891. begin
  892.   SetROP2(MultiImage1.Canvas.handle, R2_NOT);
  893.   MultiImage1.Canvas.moveto(pointStart.x, pointStart.y);
  894.   MultiImage1.Canvas.lineto(pointStart.x, pointEnd.y);
  895.   MultiImage1.Canvas.lineto(pointEnd.x, pointEnd.y);
  896.   MultiImage1.Canvas.lineto(pointEnd.x, pointStart.y);
  897.   MultiImage1.Canvas.lineto(pointStart.x, pointStart.y);
  898. end;
  899. {---------------------------------------------------------------------}
  900.  
  901. procedure TViewImageForm.Button3Click(Sender: TObject);
  902. begin
  903.   {Flip the image}
  904.   MultiImage1.FlipImage;
  905. end;
  906. {---------------------------------------------------------------------}
  907.  
  908. procedure TViewImageForm.Button2Click(Sender: TObject);
  909. begin
  910.   {Rotate the image}
  911.   MultiImage1.RotateImage;
  912. end;
  913. {---------------------------------------------------------------------}
  914.  
  915. procedure TViewImageForm.Button4Click(Sender: TObject);
  916. begin
  917.   {Reset the image to its original size/position}
  918.   MultiImage1.ResetImage;
  919. end;
  920. {---------------------------------------------------------------------}
  921.  
  922. procedure TViewImageForm.TiffComboChange(Sender: TObject);
  923. begin
  924.    {Set the compression method to save tiffs}
  925.    if TiffCombo.Text ='NONE' then
  926.     MultiImage1.TifSaveCompress:=sNONE;
  927.  
  928.    if TiffCombo.Text ='CCITT' then
  929.     MultiImage1.TifSaveCompress:=sCCITT;
  930.  
  931.    if TiffCombo.Text ='LZW' then
  932.     MultiImage1.TifSaveCompress:=sLZW;
  933.  
  934.    if TiffCombo.Text ='PACKBITS' then
  935.     MultiImage1.TifSaveCompress:=sPACKBITS;
  936. end;
  937. {---------------------------------------------------------------------}
  938.  
  939. procedure TViewImageForm.Scan1Click(Sender: TObject);
  940. begin
  941.     {Scan an image using a twain scanner}
  942.     MultiImage1.ScanImage(Handle);
  943. end;
  944. {---------------------------------------------------------------------}
  945.  
  946. procedure TViewImageForm.SelectScanner1Click(Sender: TObject);
  947. begin
  948.     {Select a twain scanner source}
  949.     MultiImage1.SelectScanner(Handle);
  950. end;
  951. {---------------------------------------------------------------------}
  952.  
  953. procedure TViewImageForm.FormClose(Sender: TObject;
  954.   var Action: TCloseAction);
  955. begin
  956.     Application.OnIdle:=Nil;
  957.    {Unregister the callback procedure}
  958.     TPMultiImageCallBack:=nil;
  959.    {release memory of the stringlist boxes}
  960.     oldsavefiles.free;
  961.     oldreadfiles.free;
  962.     ViewImageForm:=Nil;
  963.     Action:=caFree;
  964. end;
  965.  
  966. {---------------------------------------------------------------------}
  967.  
  968. procedure TViewImageForm.OpenUsingThumbnails1Click(Sender: TObject);
  969. begin
  970.  
  971.  ThumbPreview1.PreviewsDir:='d:\';
  972.  ThumbPreview1.DataFileDir:='d:\';
  973.  
  974.  If ThumbPreview1.Execute then  begin
  975.  
  976.     SstretchOnOff(Sender);
  977.     {Reset image sizes}
  978.     MultiImage1.Height:=239;
  979.     MultiImage1.Width:=334;
  980.  
  981.    {set hourglass cursor}
  982.     screen.cursor:=crHourGlass;
  983.  
  984.    {delete the old image}
  985.     MultiImage1.imagename:='';
  986.  
  987.     {display an image using the vcl}
  988.     MultiImage1.imagename:=ThumbPreview1.filename;
  989.  
  990.    {Request fileinfo from the DLL}
  991.    {Note, fileinfo will not work on WMF and ICO}
  992.     if GetInfoChecked.Checked then
  993.       DisplayInfo(true) else DisplayInfo(false);
  994.  
  995.     {reset the gauge}
  996.     Gauge1.Progress:=0;
  997.  
  998.    {add filename to the history list of the open dialog}
  999.     oldreadfiles.add(OpenDialog1.filename);
  1000.  
  1001.    {copy the stringlist to the historylist}
  1002.     OpenDialog1.historylist:=oldreadfiles;
  1003.  
  1004.    {set default cursor}
  1005.     screen.cursor:=crDefault;
  1006.   end;
  1007. end;
  1008.  
  1009.  
  1010. end.
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.